<template>
  <div class="time">
    <div class="timenow">{{t}}</div>
    <div class="date">{{ day }}</div>
  </div>
</template>

<script>
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'

dayjs.locale('zh-cn')
export default {
  name: 'DateView',
  data() {
    return {
      t: dayjs().format('HH:mm:ss'),
      day: dayjs().format('YYYY年MM月DD日 dddd'),
      n: null
    }
  },
  mounted() {
    this.n = setInterval(() => {
      this.t = dayjs().format('HH:mm:ss')
      this.day = dayjs().format('YYYY年MM月DD日 dddd')
    }, 1000)
  },
  beforeDestroy() {
    clearInterval(this.n)
  }
}
</script>

<style scoped>

</style>
